package aad.storyboard.controller;



import aad.storyboard.model.Chapter;
import aad.storyboard.model.Scene;
import aad.storyboard.model.Story;
import aad.storyboard.model.Chapter.ChapterChangeListener;
import aad.storyboard.view.GraphicView;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.view.animation.AccelerateInterpolator;
import android.widget.RelativeLayout;

public class StoryController{

	private static Chapter currentChapter;
	private Chapter nextChapter;
	private static Scene currentScene;	
	private static Scene nextScene;
	
	private static RelativeLayout gCurrentScene;
	private static RelativeLayout gNextScene;
	
	
	private static Boolean forward;
	
	private static Handler mHandler=new Handler();
	
	private static StoryController inst = new StoryController();

	private StoryController(){}
	
	public static StoryController getInstance(Chapter chapter){		
		
		Story.getCurrentChapter().setChapterChangeListener(new ChapterChangeListener(){
			@Override
			public void onChapterChange(Chapter chapter) {
				currentScene=chapter.getCurrentScene();
				nextScene=chapter.getNextScene(currentScene);
				gCurrentScene=Story.getgScene();
				//System.out.println("Handler aufgerufen");
				    if (gCurrentScene!=null)
				    	{	
				    	System.out.println("Handler aufgerufen2");
				    	//mHandler.removeCallbacks(mUpdateTimeTask);
				    	
		                //mHandler.postDelayed(mUpdateTimeTask, 100);
				    	}
			}});
		return inst;
				
	}
	
	private static Runnable mUpdateTimeTask = new Runnable() {
		   public void run() {
		       aad.storyboard.transitions.TransitionProvider.applyTransition(gCurrentScene);	   
		   }
		};
	
}
